#ifndef AUDIO_H
#define AUDIO_H

#include <string>
#include <portaudio.h>

class AudioPlayer {
public:
    AudioPlayer();
    ~AudioPlayer();
    
    // 初始化PortAudio
    bool initialize();
    
    // 播放提示音
    void playBeep();
    
    // 播放莫尔斯码音频
    void playMorseCode(const std::string& morseCode, int frequency, int baseTimeMs);
    
    // 停止播放
    void stop();
    
private:
    PaStream *stream;
    bool isPlaying;
    
    // 音频回调函数
    static int paCallback(const void *inputBuffer, void *outputBuffer, 
                         unsigned long framesPerBuffer, 
                         const PaStreamCallbackTimeInfo* timeInfo, 
                         PaStreamCallbackFlags statusFlags, 
                         void *userData);
    
    // 生成正弦波数据
    void generateSineWave(float* buffer, unsigned long frames, float frequency, float amplitude = 0.5f);
};

#endif // AUDIO_H